package factory;


import org.springframework.beans.factory.FactoryBean;

import java.sql.Connection;
import java.sql.DriverManager;


public class MyBeanFactory implements FactoryBean {

    @Override
    public Object getObject() throws Exception {
        //加载驱动
        Class.forName("com.mysql.jdbc.Driver");
        //创建连接
        return DriverManager.getConnection("jdbc:mysql://localhost:3306/xsh?useUnicode=true&characterEncoding=utf8"
        ,"cos","123456");
    }


    @Override
    public Class<?> getObjectType() {
        return Connection.class;
    }


    @Override
    public boolean isSingleton() {
        return false;
    }
}
